﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using User.API.Data.Core;

namespace User.API.Data.Mapping
{
    public class ApplicationUserMap
        : IEntityTypeConfiguration<ApplicationUser>
    {
        public void Configure(EntityTypeBuilder<ApplicationUser> builder)
        {
            //Table.
            builder.ToTable("ApplicationUser");
            //Key.
            builder.HasKey(t => t.Id);
            //Props.
            builder.Property(t => t.Avatar)
                .HasColumnName("Avatar")
                .HasMaxLength(200)
                .IsUnicode(true)
                .IsRequired(false);
            builder.Property(t => t.Name)
                .HasColumnName("Name")
                .HasMaxLength(20)
                .IsUnicode(true)
                .IsRequired(true);
            builder.Property(t => t.Phone)
                .HasColumnName("Phone")
                .HasMaxLength(15)
                .IsUnicode(true)
                .IsRequired(true);
            builder.Property(t => t.Title)
                .HasColumnName("Title")
                .HasMaxLength(20)
                .IsUnicode(true)
                .IsRequired(false);
            builder.Property(t => t.Company)
                .HasColumnName("Company")
                .HasMaxLength(20)
                .IsUnicode(true)
                .IsRequired(false);
        }
    }
}
